from neo4j_db.operation import (
    matchNode,
    matchNodeByKeyword,
    getRelationshipByTwoNode
)
from neo4j_db.nodeType import (
    HERO_NODE_TYPE,
)
# 根据名称获取结点，如果没有的话，就根据关键词模糊搜索
def getNodeByNameOrKeyword(word):
    # 按名称查询
    nodes = matchNode(name = word)
    if len(nodes) > 0:
        return nodes
    # 直接进行模糊查询,因为名字也在keyword里面
    nodes = matchNodeByKeyword(HERO_NODE_TYPE, word)
    if len(nodes) == 0:
        return None
    else:
        return nodes

def matchTwoNodeAndReturnRelationship(node1, node2):
    relationships = getRelationshipByTwoNode(node1, node2)
    return relationships

def matchAllAboutNodeAndReturnRelationship(node):
    relationships = getRelationshipByTwoNode(node)
    return relationships
